package com.ziyun.erp.modules.order.service.impl;

import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import com.ziyun.erp.modules.order.dao.UserPaymentDao;
import com.ziyun.erp.modules.order.entity.UserPaymentEntity;
import com.ziyun.erp.modules.order.service.UserPaymentService;


@Service("userPaymentService")
public class UserPaymentServiceImpl extends ServiceImpl<UserPaymentDao, UserPaymentEntity> implements UserPaymentService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        Page<UserPaymentEntity> page = this.selectPage(
                new Query<UserPaymentEntity>(params).getPage(),
                new EntityWrapper<UserPaymentEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public UserPaymentEntity getPaySuccLastEntityByOrderId(String orderId) {
        return this.baseMapper.getPaySuccLastEntityByOrderId(orderId);
    }

    @Override
    public boolean updateByMap(Map<String, Object> updateMap, String paymentId) {
        int update = this.baseMapper.updateByMap(updateMap, paymentId);
        if (update == 0){
            return false;
        }
        return true;
    }

    @Override
    public List<UserPaymentEntity> queryOrderPaymentInfo(String orderId) {
        List<UserPaymentEntity> list =  baseMapper.queryOrderPaymentInfo(orderId);
        return list;
    }

}
